package com.deke.order.service.Impl;

import cn.hutool.core.util.ObjectUtil;
import com.deke.entity.EduCourse;
import com.deke.order.dao.QianOrderCourseDao;
import com.deke.order.service.QianOrderCourseService;
import com.deke.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author ：Username 刘亦辰（59372312@qq.com）
 * @date ：Created in 2022/12/30 11:57
 * @description：
 * @modified By：
 * @version:
 **/
@Service
public class QianOrderCourseServiceImpl implements QianOrderCourseService {

    @Autowired
    QianOrderCourseDao orderCourseDao;
    
    /**
     * @create by: Username 刘亦辰 
     * @description: 根据课程id 查询 课程信息和老师名称 
     * @create time: 2022/12/30 13:50
     * @param null 
     * @return :  
     **/
    @Override
    public Result queryAllCourseAndTeacherName(String id) {
        EduCourse eduCourse = orderCourseDao.queryAllCourseAndTeacherName(id);
        if (ObjectUtil.isNotEmpty(eduCourse)){
            return new Result(2000,"成功",eduCourse);
        }
        return new Result(0000,"无数据",null);
    }
    
    
    /**
     * @create by: Username 刘亦辰 
     * @description: 根据课程id 和 用户手机号 判断当前用户是否为 讲师 
     * @create time: 2022/12/30 13:57
     * @param null 
     * @return :  
     **/
    @Override
    public Result queryMemberStatus(String id, String mobileId) {
        Integer isType = null;
        Integer integer = orderCourseDao.queryMemberStatus(id, mobileId);
        if(ObjectUtil.isNotEmpty(integer)){
            isType=1;
            return new Result(2000,"讲师",isType);
        }
        isType = 0;
        return  new Result(2000,"学生", isType);
    }
    
    
    /**
     * @create by: Username 刘亦辰 
     * @description: 判断该视频是否为该讲师发布的 
     * @create time: 2022/12/30 16:11
     * @param null 
     * @return :  
     **/
    @Override
    public Result queryAllById(String id, String mobileId) {
        Integer integer = orderCourseDao.queryAllById(id, mobileId);
        if (ObjectUtil.isNotEmpty(integer)){
            return new Result(2000,"是",true);
        }
        return new Result(0000,"否",false);
    }
}